package com.jungle.mvvm.sample.binding.banner;


import android.databinding.BindingAdapter;

import com.jungle.mvvm.binding.command.BindingCommand;
import com.jungle.mvvm.utils.KLog;
import com.youth.banner.Banner;
import com.youth.banner.listener.OnBannerListener;

import java.util.List;


/**
 * Created by goldze on 2017/6/16.
 * TwinklingRefreshLayout列表刷新的绑定适配器
 */
public class ViewAdapter {

    @BindingAdapter(value = {"itemDatas", "onItemCommand"})
    public static void setItemDatas(Banner banner, final List<String> itemDatas, final BindingCommand<Integer> onItemCommand) {
        banner.setImages(itemDatas).setImageLoader(new GlideImageLoader()).start();

        banner.setOnBannerListener(new OnBannerListener() {
            @Override
            public void OnBannerClick(int position) {
                KLog.e("test", position);
                if (onItemCommand != null) {
                    onItemCommand.execute(position);
                }
            }
        });

    }
}
